﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Drawing;

namespace ImageProcessingLibrary
{
    internal class SkinColorAreas
    {
        internal readonly List<Rectangle> skinColorAreas; //rectangles in Cb-Cr-space defining skin colored pixels

        internal SkinColorAreas()
        {
            this.skinColorAreas = LoadAreasFromFile("colorareas");
        }

        private List<Rectangle> LoadAreasFromFile(string FileName)
        {
            List<Rectangle> rectangles = new List<Rectangle>();

            FileStream fs = new FileStream(FileName, FileMode.Open, FileAccess.Read);
            BinaryReader br = new BinaryReader(fs);
            int nrOfElements = br.ReadInt32();
            for (int i = 0; i < nrOfElements; i++)
            {
                int x = br.ReadInt32();
                int y = br.ReadInt32();
                int width = br.ReadInt32();
                int height = br.ReadInt32();

                rectangles.Add(new Rectangle(x,y,width,height));
            }
            br.Close();
            fs.Close();

            return rectangles;
        }
    }
}
